﻿<%@ Control Language="C#" Inherits="LarDosIdosos.WebUserControlResponsavel" %>
<asp:UpdatePanel ID="updatePanelResponsavelWebUserControl" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    
	<div style="float:left;margin-bottom:30px;margin-right:30px;" ID="divPrintJs" runat="server" Visible="false">
        <script src="jscript/jquery-1.8.2.min.js" type="text/javascript"></script>
        <script src="jscript/jquery.printElement.js" type="text/javascript"></script>
        <script  type="text/javascript">
            function PrintDiv() {
                $('#divPrint').printElement();
            }
        </script>
		<a href='#' onclick="PrintDiv()">
			<asp:Image BorderWidth="0" runat="server" ID="imagePrint" ImageUrl="~/Imagens/IconPrintPage.png" style="margin-right:20px;" ToolTip="Imprimir este cadastro"/>
		</a>
	</div>

    <div id="divPrint" style="float:left; width:100%;">
        
        <asp:HiddenField ID="hiddenFieldCodigoResponsavel" runat="server" />
        <div style="float:left;width:100%;text-align:center;">
            <asp:Label ID="labelFeedback" runat="server" Text=""/>
        </div>
        <table width="100%" cellspacing="20px">
            <tr>
                <td style="width:20%;">
                    Nome do Responsável:
                </td>
                <td>
                    <asp:TextBox ID="textNomeDoResponsavel" runat="server" Style="width:90%"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Estado Civil:
                </td>
                <td>
                    <asp:DropDownList ID="dropDownListEstadoCivil" runat="server">
                        <asp:ListItem Text="Solteiro" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Casado" Value="2"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    CPF:
                </td>
                <td>
                    <asp:TextBox ID="textCpfDoResponsavel" runat="server" CssClass="cpf"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    RG:
                </td>
                <td>
                    <asp:TextBox ID="textRgDoResponsavel" runat="server"></asp:TextBox>
                </td>
            </tr>
		    <tr>
                <td>
                    Telefones:
                </td>
                <td>
                    <table width="100%">
                        <asp:Repeater id="repeaterTelefones" runat="server" OnItemCommand="repeaterTelefones_ItemCommand">
                            <ItemTemplate>
                            <tr>
								<td><asp:HiddenField ID="hiddenFieldCodigoTelefone" runat="server" Value='<%# Eval("Codigo_Telefone") %>' /><asp:Literal ID="literalNumero" runat="server" Text='<%# Eval("Numero_Telefone") %>'></asp:Literal></td><td><asp:ImageButton id="imageButtonRemover" runat="server" CommandName="deletar" CommandArgument='<%# Eval("Codigo_Telefone") %>' AlternateText="Excluir"/></td>
                            </tr>
							</ItemTemplate>
                        </asp:Repeater>
                        <asp:Repeater id="repeaterTelefonesVisualizacao" runat="server">
                            <ItemTemplate>
                            <tr>
								<td><asp:Literal ID="literalNumero" runat="server" Text='<%# Eval("Numero_Telefone") %>'></asp:Literal></td>
                            </tr>
							</ItemTemplate>
                        </asp:Repeater>
                        <tr id="trAddTelefone" runat="server">
						    <td colspan="2"><asp:TextBox id="textBoxAddTelefone" runat="server" CssClass="telefone"></asp:TextBox><asp:Button id="buttonAddTelefone" runat="server" OnClick="buttonAddTelefone_Click" Text="Adicionar"></asp:Button></td>
					    </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    Data de Nascimento:
                </td>
                <td>
                    <asp:TextBox ID="textDataDeNascimento" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Nome do Pai:
                </td>
                <td>
                    <asp:TextBox ID="TextBoxNomeDoPai" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Nome da Mãe:
                </td>
                <td>
                    <asp:TextBox ID="TextBoxNomeDaMae" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr id="trIdosos" runat="server">
                <td colspan="2">
                   Idosos:<br />
                   <asp:GridView
                        ID="gridViewIdosos"
                        runat="server"
                        Width="70%"
                        AutoGenerateColumns="False"
				        BackColor="#E9E9E9"
				        GridLines="None"
                        CellPadding="2"
                        >
                        <AlternatingRowStyle BackColor="#f7f7f7"/>
				        <HeaderStyle BackColor="#EEEEEE" ForeColor="Black" />
					    <RowStyle Height="50px" BackColor="#FFFFFF"/>
                        <EmptyDataRowStyle BackColor="#F7F7F7" Height="100px" VerticalAlign="Middle" HorizontalAlign="Center" />
                        <EmptyDataTemplate >
                            Nenhum Idoso Encontrado
                        </EmptyDataTemplate>
                        <Columns>
                            <asp:TemplateField HeaderStyle-Width="1%" ShowHeader="false">
					            <ItemTemplate>
                                    <asp:HiddenField ID="hiddenFieldId" runat="server" Value='<%# Eval("Codigo_Idoso") %>' />
				                </ItemTemplate>
				            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Nome">
				                <ItemTemplate> 
				                    <asp:Label ID="labelNomeDoIdoso" runat="server" Text='<%# Eval("Nome_Idoso") %>' ></asp:Label>
				                </ItemTemplate>
				                <headerstyle Width="30%"/>
				            </asp:TemplateField>
                            <asp:TemplateField HeaderText="CPF">
				                <ItemTemplate> 
				                    <asp:Label ID="labelCpfDoIdoso" runat="server" Text='<%# Eval("CPF_Idoso") %>' ></asp:Label>
				                </ItemTemplate>
				                <headerstyle Width="20%"/>
				            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Grau de paremtesco com o idoso">
				                <ItemTemplate> 
				                    <asp:Label ID="labelGrauDeParentesco" runat="server" Text='<%# Eval("Grau_de_Parentesco") %>' ></asp:Label>
				                </ItemTemplate>
				                <headerstyle Width="30%"/>
				            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td>
                                   
                </td>
                <td>
                    <asp:Button ID="buttonSalvar" runat="server" Text="Salvar" OnClick="buttonSalvar_Onclick" Visible="false"/>
                </td>
            </tr>
        </table>
                            
    </div>
    </ContentTemplate>
	<Triggers>
        <asp:PostBackTrigger ControlID="repeaterTelefones" />
        <asp:PostBackTrigger ControlID="buttonAddTelefone" />
		<asp:PostBackTrigger ControlID="buttonSalvar" />
	</Triggers>
</asp:UpdatePanel>
<script type="text/javascript">
    carregarCalendario = function () {
        $("#<%= textDataDeNascimento.ClientID %>").datepicker({ dateFormat: "dd/mm/yy" });
    };

    carregarMascara = function () {
        $("#<%= textCpfDoResponsavel.ClientID %>").mask("999.999.999-99");
        $(".telefone").mask("(999)9999-9999");
    };
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(carregarCalendario);
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(carregarMascara);
</script>
